<script setup lang="ts">
import moment from "moment";
import { ref } from "vue";
defineProps(["list", "title"]);
const infos = ref();
let show = ref(true);
const handleIsShow = () => {
  show.value = !show.value;
  console.log(show.value);
};

const formatMDtime = (time) => {
  return moment(parseInt(time)).format("MM-DD");
};
</script>

<template>
  <div class="item">
    <div class="left">
      <div class="out-icon">
        <div class="in-icon"></div>
      </div>
      <div class="line"></div>
    </div>
    <div class="right">
      <div class="content" @click="handleIsShow">
        <span>{{ title }}</span>
        <el-icon>
          <component :is="show ? 'ArrowDown' : 'ArrowUp'"></component>
        </el-icon>
      </div>
      <Transition>
        <div class="artilce-infos" v-show="show">
          <router-link v-for="item in list" :key="item.id" :to="`/article/${item.id}`"
            >{{ formatMDtime(item.createTime) }}: {{ item.title }}</router-link
          >
        </div>
      </Transition>
    </div>
  </div>
</template>

<style scoped lang="scss">
.item {
  display: flex;
  .left {
    .out-icon {
      margin-top: 8px;
      z-index: 9;
      width: 16px;
      height: 16px;
      display: flex;
      justify-content: center;
      border-radius: 50%;
      align-items: center;
      box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.1);
      background-color: rgb(14 116 218 / 10%);
      .in-icon {
        width: 10px;
        height: 10px;
        background-color: $strong;
        border-radius: 5px;
      }
    }
    .line {
      position: relative;
      top: -5px;
      margin-left: 6px;
      width: 5px;
      height: 100%;
      background: $strong;
      opacity: 0.1;
    }
  }
  .right {
    margin-left: 30px;
    flex: 1;
    padding-bottom: 20px;
    .content {
      cursor: pointer;
      position: relative;
      height: 35px;
      line-height: 35px;
      padding-left: 10px;
      background: #f2f6fc;
      border-radius: 5px;
      color: $strong;
      font-size: 14px;
      &::after {
        position: absolute;
        content: "";
        width: 0;
        height: 0;
        top: 8px;
        left: -18px;
        border: 10px solid transparent;
        border-right: 10px solid #f2f6fc;
      }
      :deep .el-icon {
        position: absolute;
        right: 10px;
        top: 10px;
      }

      span {
        margin-left: 10px;
      }
    }
    .artilce-infos {
      margin-top: 20px;
      a {
        display: block;
        margin-left: 20px;
        margin-bottom: 16px;
        font-family: "隶书";
        font-weight: 500;
        &:hover {
          color: $strong;
        }
      }
    }
  }
}
.v-enter-active,
.v-leave-active {
  transition: all 0.5s ease;
}

.v-enter-from,
.v-leave-to {
  opacity: 0;
}
</style>
